<?php
	####################################################
	# library import and object instance.              #
	####################################################
	include_once('./common.php');
	include_once('./ncrud_common.php');


	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	$req = Request::clean_request($_REQUEST, FALSE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)
	//*/
	Validation::check_is_emptys($req);
	//*/

	####################################################
	# implementation                                   #
	####################################################
	//*/
	$article = $db->get(
		sprintf("SELECT * FROM `%s` WHERE `buid`= '%s'",
			$ncrud['table_name'],
			$req['buid']
		)
	);
	//Nlog::xmp($article);
	//*/
?>
<?php
	$html->custom_header(TITLE);
	$html->custom_js("{$JS}jquery.1.7.1.min.js");
	$html->custom_js("{$JS}lib.control.js");
	$html->custom_css("{$CSS}basic.css");
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
	var PageAction = {
		validate:function(){
			//*/
			var check = [
				Validation.check_is_null("#bname", "이름을 입력 하세요."),
				Validation.check_is_null("#bname_eng", "이름(영문)을 입력 하세요."),
				Validation.check_is_do_not_chooesed("benable", "활성을 선택 하세요."),
				Validation.check_is_null_textarea("#bdesc", "데스크립션을 입력 하세요.")
			];
			return Validation.check(check);
			//*/
		}
	}
//]]>
</script>
<?$html->custom_body();?>
<?=$tmp->tiles_header()?>
	<h1>ncrud - update</h1>
	<form id="formx" name="formx" method="post" action="./ncrud_update_proc.php" onsubmit="return PageAction.validate();">
		<input type="hidden" name="buid" id="buid" value="<?=$article['res']['buid']?>" />
		<table width="100%" border="1" cellspacing="3" cellpadding="0">
			<tr>
				<th>
					유니크 아이디(buid)
				</th>
				<td>
					<?=$article['res']['buid']?>
				</td>
			</tr>
			<tr>
				<th>
					이름(bname)
				</th>
				<td>
					<input type="text" name="bname" id="bname" value="<?=$article['res']['bname']?>" />
				</td>
			</tr>
			<tr>
				<th>
					이름-영문(bname_eng)
				</th>
				<td>
					<input type="text" name="bname_eng" id="bname_eng" value="<?=$article['res']['bname_eng']?>" />
				</td>
			</tr>
			<tr>
				<th>
					활성(benable)
				</th>
				<td>
					<label>
						<input type="radio" name="benable" id="benableY" value="Y" <?=NForm::checked($article['res']['benable'], "Y")?> /> Y
					</label>
					<label>
						<input type="radio" name="benable" id="benableN" value="N" <?=NForm::checked($article['res']['benable'], "N")?> /> N
					</label>
				</td>
			</tr>
			<tr>
				<th>
					데스크립션(bdesc)
				</th>
				<td>
					<textarea id="bdesc" name="bdesc" rows="5" cols="80"><?=$article['res']['bdesc']?></textarea>
				</td>
			</tr>
			<tr>
				<th>
					시간(bdate)
				</th>
				<td>
					<?=$article['res']['bdate']?>
				</td>
			</tr>
			<tr>
				<th colspan="2">
					<?=NTool::submit_btn();?>
				</th>
			</tr>
		</table>
	</form>
	<?=NTool::btn("조회", "Mover.href('./ncrud_retrieve.php?buid={$article['res']['buid']}');");?>
	<?=NTool::btn("리스트", "Mover.href('./ncrud_list.php');");?>
	<span> | </span>
	<?=NTool::btn("뒤로", "Mover.back();");?>
	<?=NTool::btn("인덱스", "Mover.home();");?>
<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>